<%-- 
    Document   : products
    Created on : Dec 29, 2011, 11:15:59 PM
    Author     : user
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@include file="../jspf/header.jspf" %>

<%
    session.setAttribute(Static.pageSort, "products");
%>


<div style="width: 100%">
    <p class="pageTitle"><strong><?php echo $category ["Name"] . '/ ' . $subCategory ["Name"] ?></strong></p>
    <br />
    <div style="width: 100%">
        <hr />
    </div>
    <div class="divPaginare">

        <%@include file="../jspf/sort.jspf" %>
        <%@include file="../jspf/pagining.jspf" %>

    </div>

    <div style="width: 100%; margin-top: 15px">
        <hr />
    </div>

    <%
        try {
            ArrayList products = (ArrayList) session.getAttribute(Static.products);
            // session.setAttribute(Static.products, null);

            int s = products.size();

            for (int i = 0; i < s; i++) {
                HashMap prod = (HashMap) products.get(i);

                out.println("<div class=\"divProductsList\">");
                out.println("<div class=\"divProductBox\">");
                out.println("<div><b>" + prod.get("Name") + "</b></div>");
                out.println("<div class=\"divProductsBox Picture\">");
                out.print("<a href=\"products?action=details&prodID=" + prod.get("ProductID") + "\"> <img src=\"img/products/");

                String picturePath = (String) prod.get("Photo");
                if (picturePath.compareTo("") == 0) {
                    picturePath = "imagenotfound.jpg";
                }

                out.print(picturePath);
                out.println("\" width=\"120px\" height=\"100px\" alt=\"Detalii\" title=\"Detalii produs\" /> </a> ");
                out.println("</div>");
                out.println("<div class=\"divProductsBox Details\">");
                out.println("<div><b>Pret: " + prod.get("Price") + " RON </b></div>");
                out.println("<div><b>Cant: " + prod.get("Quantity") + "</b></div>");
                out.println("<div style=\"margin-top: 5px\">");

                if ((Float) prod.get("Quantity") > 0) {
                    out.println("<img src=\"img/site/add.gif\" onclick=\"addProduct(" + prod.get("ProductID") + ")\" alt=\"Comanda\" width=\"80px\" title=\"Adauga in cos\" style=\"cursor:pointer\"/>");
                } else {
                    out.println("<img src=\"img/site/add.gif\"  alt=\"Comanda\" width=\"80px\" title=\"Nu exista stoc pentru aces produs\" style=\"enable:false; cursor:pointer\"/>");
                }
                out.println("</div></div></div></div>");
            }
        } catch (Exception ex) {
            out.println(ex.getMessage());
        }
    %>

    <div class="divProductsList Bottom">
        <hr />
        <div class="divPaginare" style="text-align: right">

            <%@include file="../jspf/pagining.jspf" %>

        </div>
    </div>
</div>
<%@include file="../jspf/footer.jspf" %>
